import csv
# 列表写入CSV
with open('list-to-csv.csv', 'w',encoding='utf-8-sig',newline='') as csvf:
    writer = csv.writer(csvf,delimiter =',')
    writer.writerow(['id\n','name','age'])
    writer.writerow(['1','wr','23'])
    writer.writerow(['3','ff','45'])


#字典写入csv
# a={
#     'index':1,
#     'image':'misi'
# }
# with open('tuple-to-csv.csv','w',newline='') as f:
#     fieldnames = ['index', 'image']
#     writer = csv.DictWriter(f, fieldnames=fieldnames)
#     writer.writeheader()
#     writer.writerow(a)
